<html>
<head>
	<meta charset='utf-8' />
	<title>后台管理</title>
	<meta http-equiv="keywords" content="求职,招聘,房屋,出租,出售,求租,求购,宠物,二手,二手车,二手物品,旧货,寻物,寻人,出兑,外兑"> 
	<meta http-equiv="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息">  
	<meta name="description" content="便民信息网,房屋租售,宠物交易,二手物品,二手车辆,寻物寻人,出兑信息"/>
	<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
	<style>
		@media screen and (max-width:450px){
			#nav_bottom{width:98%;margin:0 auto}
			#content{width:98%;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		@media screen and (min-width:450px){
			#nav_bottom{width:450px;margin:0 auto}
			#content{width:450px;margin:0 auto}
			/*页面宽度900以下时 .abc的宽度为450*/
		}
		.info_item{color:#444;margin:15px 0;display:flex}
		.info_item > div:last-child{flex:1}
	</style>
</head>
<body style='padding:0;margin:0;background:#eee'>
<!-- 1 Content容器 -->
<div id='Content'>
	<!-- 3 内容区-->
	<div style='margin:10px 0;word-break:break-all;padding:10px;'>
		<div style='float:right;text-align:right' onclick='After_Admin_Exit()'>退出</div>

		<h2 style='text-align:center;'>后台管理-用户组设置</h2>
		<div>当前用户：<span id='group_name'></span></div>
		<hr>
		
	

		<div id='a'></div>

		<!--修改密码浮动区-->
		<div id='admin_group_fun_list' style=''>
			<div>分组选择：</div>
			<div id='group_list'>


		
				<!--div style='margin:20px auto'>
					<div>
						<input type="radio" name='groups' /> 组名：aa1 (说明 。。。。。。)
					</div>
					<div style='text-indent:50px'>
						<div>
							页面：a1
							<div style='text-indent:100px'>功能：a11</div>
						</div>
					</div>
				</div-->




			</div>
		</div>

			
	
	</div>	<!-- 3 内容区结束-->	

</div><!-- 1 Content容器结束 -->







<!--底部导航容器-->
<div id='Nav_Bottom' style='position:fixed;bottom:0;width:100%;height:45px'>



</body>
</html>


<script src='./Public/jquery.js'></script>
<script src='./Public/fun.js'></script>
<script>
	Check_After_User_Cookie();	//检测登陆状态
	

	var priv_name = 'after_set_user_change_group';
	Priv_Check(priv_name,function(res){
		if(res != 'ok'){
			alert('没有权限!');
			//location.href = document.referrer;
			exit;
		}
	});






	//加载底部导航栏
	Load_NavBottom('after');

	$(function(){

		//获取当前用户
		$('#group_name').text(GetUrlParm('uname'));


	
		var type='After_Get_GroupOrFuns';
		Token(type,function(t){
			$.ajax({
				url:url,
				type:'post',
				data:{
					token:t,
					type:type,
				},
				success(res){
				//	alert(res);
					var data = JSON.parse(res);
					var list_str = '';
					for(var i=0;i<data.length;i++){
						list_str += "<div style='border-bottom:1px solid #aaa;padding:20px 0'>";
						list_str += "<div>";
						var gid = GetUrlParm('gid');
						if( gid != 'err' && gid == data[i].id){
							var checked = 'checked';
						}else{
							var checked = '';
						}
						list_str += "<input type='radio' name='groups' value='"+data[i].id+"-----"+data[i].name+"' "+checked+" /> 组名："+data[i].name;
						list_str += "</div>";
						list_str += "<div style='text-indent:50px'>分组说明："+data[i].name+"</div>";
						list_str += "<div style='text-indent:50px'>拥有权限：</div>";
						if(data[i].pList){
							for(var x=0;x<data[i].pList.length;x++){
								list_str += "<div style='text-indent:100px'>";
								//list_str += "<div>";
								list_str += "页面："+data[i].pList[x].explains;
								if(data[i].pList[x].sub){
									for(var w=0;w<data[i].pList[x].sub.length;w++){
										list_str += "<div style='text-indent:150px'>功能："+data[i].pList[x].sub[w].explains+"</div>";
									}
								}
								list_str += "</div>";
							}
						}
						list_str += "</div>";
						list_str += "</div>";
					}
					list_str += "<div style='margin:20px;text-align:center'>";
					list_str += "<button onclick='After_User_Change_Group()'>提交</button>　";
					list_str += "<button onclick='Go_Back()'>返回</button>";
					list_str += "<div style='height:100px'></div>";
					$("#group_list").html(list_str);
				}
			});
		});



	});

	function After_User_Change_Group(){
		var priv_name = 'AfterSetUserChangeGroup_Submit';
		Priv_Check(priv_name,function(res){
			if(res != 'ok'){
				alert('没有权限!');
				//location.href = document.referrer;
				exit;
			}
		});
		var val = $('input[name=groups]:checked').val();
		if(!val){
			alert('请选择分组!');return;
		}else{
			var arr = val.split("-----",2);
			if(arr.length <2){
				alert('异常!');return;
			}
			var gid = arr[0];
			var gname = arr[1];
			var type = 'After_User_Change_Group';
			Token(type,function(t){
				$.ajax({
					url:url,
					type:'post',
					data:{
						type:type,
						token:t,
						gid:gid,
						gname:gname,
						uid:GetUrlParm('uid')
					},
					success(res){
						if(res == 'ok'){
							alert('操作成功!');
							Go_Back();
						}else{
							alert('操作失败!');
						}
					}

				});
			});
		}
	}

	//返回分组页面
	function Go_Back(){
		location.href='after_set_user.html';
	}

</script>

